




const fs = require('fs')
// 文件操作路径
const path = require('path')

/**
 * ./ 相对路径 相对于当前目录  真实的./ 是相对与 node命令所在的目录
 * ../ 相对于上一级目录
 */
// fs.readFile('./a.txt','utf8',(err,data)=>{
//     if(err){
//         console.log(err);
//     }
//     console.log(data);
// })
// fs.readFile('E:\\CodeDemo\\19级前端课程\\nodejs19demo\\05文件系统\\a.txt','utf8',(err,data)=>{
//     if(err){
//         console.log(err);
//     }
//     console.log(data);
// })
fs.readFile(path.join(__dirname,'./a.txt'),'utf8',(err,data)=>{
    if(err){
        console.log(err);
    }
    console.log(data);
})

// console.log(path);

// let p = 'E:\\CodeDemo\\19级前端课程\\nodejs19demo\\pathdemo.js'
// let obj = path.parse(p)
// console.log(obj.name);
// console.log(obj.base);
// let p2 = './a.txt'
// let isAbsolute = path.isAbsolute(p2)
// console.log(isAbsolute);

// let basename = path.basename(p)
// let extname = path.extname(p)
// let dirname = path.dirname(p)
// console.log(basename);
// console.log(extname);
// console.log(dirname);

let p1 = 'E:/a/b/c/d/e/f'
let p2 = '\\b\\c\\a.txt'
// let newp = path.join(p1,p2)

// console.log(newp);
// console.log(p1+p2+'\\\d/e/f');
console.log(path.join(p1,'./cd','/dd/','//cc//','.'));
console.log(path.join(p1,'./cd','/dd/','//cc//','.','..'));
// console.log(path.join(p1,'/cd','/dd/','//cc//'));

// console.log(path.resolve(p1,'./dd'));
// console.log(path.resolve(p1,'./dd','./cc/','./ddd'));

// console.log(__dirname);
// console.log(__filename)
